package com.weberror.frontendmonitoring.userbehaviordata.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.weberror.frontendmonitoring.result.R;
import com.weberror.frontendmonitoring.userbehaviordata.entity.Userbehaviordata;
import com.weberror.frontendmonitoring.userbehaviordata.service.UserbehaviordataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * 用户行为数据(Userbehaviordata)表控制层
 *
 * @author cnxym
 * @since 2022-08-17 20:00:55
 */
@RestController
@RequestMapping("userAction/pullUserPVOrUV")
public class UserbehaviordataController  {
    /**
     * 服务对象
     */
    @Autowired
    private UserbehaviordataService userbehaviordataService;

    /**
     * 分页查询所有数据
     *
     * @param page             分页对象
     * @param userbehaviordata 查询实体
     * @return 所有数据
     */
    @GetMapping
    public R selectAll(Page<Userbehaviordata> page, Userbehaviordata userbehaviordata) {
        return R.OK().data("userbehaviordata", userbehaviordataService.page(page, new QueryWrapper<>(userbehaviordata)));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R selectOne(@PathVariable Integer id) {
        return R.OK().data("userbehaviordata", userbehaviordataService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param userbehaviordata 实体对象
     * @return 新增结果
     */
    @PostMapping
    public R insert(@RequestBody Userbehaviordata userbehaviordata) {
        return R.OK().data("userbehaviordata", userbehaviordataService.save(userbehaviordata));
    }


}

